from django.db import models
# employees/models.py
from django.db import models


class Employee(models.Model):
    DEGREE_CHOICES = [
        ('专科', '专科'),
        ('本科', '本科'),
        ('硕士', '硕士'),
        ('博士', '博士'),
    ]

    GENDER_CHOICES = [
        ('男', '男'),
        ('女', '女'),
    ]

    STATUS_CHOICES = [
        ('在职', '在职'),
        ('离职', '离职'),
    ]

    LEVEL_CHOICES = [
        ('初级','初级'),
        ('中级','中级'),
        ('高级','高级'),
        ('专家','专家')
    ]

    work_id = models.CharField('工号', max_length=20, unique=True)
    name = models.CharField('姓名', max_length=100)
    department = models.CharField('部门', max_length=100)
    id_number = models.CharField('身份证号', max_length=18, unique=True)
    degree = models.CharField('学历', max_length=10, choices=DEGREE_CHOICES)
    position = models.CharField('职位', max_length=100)
    gender = models.CharField('性别', max_length=2, choices=GENDER_CHOICES)
    phone = models.CharField('手机号', max_length=15)
    email = models.EmailField('邮箱', blank=True)
    level = models.CharField('级别',max_length=10, choices=LEVEL_CHOICES,null=True)
    salary = models.DecimalField('薪资', max_digits=10, decimal_places=2,null=True)
    entry_time = models.DateTimeField('入职时间')
    contract_term = models.DateField('合同期限')
    status = models.CharField('状态', max_length=10, choices=STATUS_CHOICES, default='在职')
    created_at = models.DateTimeField('创建时间', auto_now_add=True)
    updated_at = models.DateTimeField('更新时间', auto_now=True)

    class Meta:
        verbose_name = '员工'
        verbose_name_plural = '员工'
        ordering = ['-created_at']

    def __str__(self):
        return f"{self.name} ({self.work_id})"

